<?php

namespace App\Http\Middleware;

use App\Lib\ApiResponse;
use Illuminate\Auth\Middleware\Authenticate as Middleware;

class Authenticate extends Middleware
{
    /**
     * Get the path the user should be redirected to when they are not authenticated.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return string|null
     */
    protected function redirectTo($request)
    {
        if (! $request->expectsJson()) {
            session()->put('target_url',$request->fullUrl());
            return route('manage.wxlogin');
        }

        return ApiResponse::fail('请登录',ApiResponse::CODE_AUTH_FAIL);
    }
}
